import unittest
from tools.driver import chrome
from selenium.webdriver.common.by import By
from time import sleep
class BaseCase(unittest.TestCase):
    def setUp(self):
        self.driver = chrome()

    def tearDown(self):
        self.driver.quit()

class BaseCaseZyl(unittest.TestCase):
    def setUp(self):
        self.driver = chrome()

    def tearDown(self):
        niche_locator = (By.LINK_TEXT, '商机')  # 商机
        all_locator = (By.ID,'check_all') # 商机全选框
        delete_btn_locator = (By.ID,'delete') # 删除按钮
        bin_locator = (By.CSS_SELECTOR,'body > div.container > p > a:nth-child(17)') # 回收站
        bin_all_locator = (By.ID,'check_all') # 全选商机框（回收站）
        self.driver.find_element(*niche_locator).click() # 点击商机
        self.driver.find_element(*all_locator).click() # 全选商机
        self.driver.find_element(*delete_btn_locator).click() # 删除商机
        self.driver.switch_to.alert.accept() # 确定删除
        self.driver.find_element(*bin_locator).click() # 点击回收站
        self.driver.find_element(*bin_all_locator).click() # 全选商机
        self.driver.find_element(*delete_btn_locator).click()  # 删除商机
        self.driver.switch_to.alert.accept()  # 确定删除
        sleep(5)
        self.driver.quit() # 退出浏览器

